package com.example.demo1.itlianxi08;

import com.example.demo1.itlianxi07.MyAnnotation;

import java.lang.annotation.Annotation;
import java.lang.annotation.Repeatable;

public class ReflectDemo3 {
    public static void main(String[] args) throws ClassNotFoundException {
        //反射对象
        Class aClass = Class.forName("com.example.demo1.itlianxi07.Student");

        //获取注解
        Annotation declaredAnnotation = aClass.getDeclaredAnnotation(MyAnnotation.class);

        if (declaredAnnotation instanceof MyAnnotation){
            MyAnnotation myAnnotation  = (MyAnnotation) declaredAnnotation;

            System.out.println(myAnnotation.name());
        }
        if (declaredAnnotation instanceof RestController){
            System.out.println("declaredAnnotation is a RestController annotation");
        }else {
            System.out.println("declaredAnnotation is not a RestController annotation");
        }
    }
}
